package com.xqls.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;
import com.xqls.bean.FluggasVocRecordBean;
import com.xqls.biz.CompanyBiz;
import com.xqls.biz.FluggasVocRecordBiz;
import com.xqls.util.CommonPage;
import com.xqls.util.CommonResult;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/fluggasController")
public class FluggasController {
	@Autowired private CompanyBiz companyBiz;
	
    @Autowired private FluggasVocRecordBiz recordBiz;
    
    @RequestMapping("/toPage")
    public ModelAndView toPage(){
    	ModelAndView view=new ModelAndView("/fluggas/vocRecordList");
    	view.addObject("companyList", this.companyBiz.getList());
    	return view;
    }
    
    @RequestMapping("/insert")
    @ResponseBody
    public String insertRecord(@RequestBody FluggasVocRecordBean beanRecord){
        return JSONObject.toJSONString(this.recordBiz.insertRealdata(beanRecord));
    }
    
    @RequestMapping("/getList")
    @ResponseBody
	public CommonResult getList(@RequestBody CommonPage commonPage, HttpServletRequest request, HttpServletResponse response){
		CommonResult result = this.recordBiz.getListByPage(commonPage,request,response);
		if (result.getIsSuccess()) {
			result.setData(commonPage);
		}
		return result;
	}
    
}
